#include "stdio.h"
#include "Function.h"
#include <string.h>


extern wangshuai;
void ANSITest()
{
//	printf("wangshuai\n");
	wangshuai = 1;
	static int wang = 11;

}

void 	sprintfTest()
{
//	printf("wangshuai\n");
	char buff[100];
	int a =1,j;
	float b =2;
	char * s = "wangshuai!";

	j = sprintf(buff,"int a = %d\n",a);
	j+=sprintf(buff+j,"float b = %f \n",b);
	j+=sprintf(buff+j,"char * s = %s\n",s);

	printf("%s",buff);
	sprintf(buff,"int a = %d\n",a);
	printf("%s\n",buff);
}

void SizeofTest()
{
	char * a = "wangshuaidfefefeffe!";
	printf("%d\n",sizeof(char*));
}

void memcypTest()
{
	char str1[2] = {'1','2'};
	char str2[6] = "6789";
	int w[3] = {1,2,3};
//	printf("%c\n",str1[2]);
}

void BitTest()
{
	/*
	for(int i = 0;i<100;i++)
	{
		int j = (i>>2);
		printf("%d>>2 = %d\n",i,j);
	}
	*/
	int HEIGHT = 10;
	int WIDTH = 10;
	int y,x,i,j;
	 for(y=0; y < HEIGHT; y++)
        for(x=0; x < WIDTH; x++)
        {
			 j = y*WIDTH + x;
            i = j*3;
			 if(x%2 == 1 && y%2 == 1)
            {
                j = (WIDTH>>1) * (y>>1) + (x>>1);
				printf("y=%d,x=%d,j=%d,y*WIDTH+x=%d,i=%d\n",y,x,j,y*WIDTH+x,i);
			 }
		}

}

void fwriteTest()
{
	FILE * fp;
	char  buff[111] = "wangshuai!wangshuai!";
	if((fp=fopen("C:\\wangshuai.txt","a")) == NULL)
	{
		printf("FILE OPEN UNSUCCESS!\n");
	}
	fread(buff,10,1,fp);
	fwrite(buff,1,strlen(buff),fp);
}